package co.fitstart.entity.course.round;

import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Type;

import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIdentityReference;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;

import co.fitstart.entity.principal.Principal;

/**
 * 课程反馈
 * @author haiyan_xiao
 *
 */
@Entity
@Table(name = "course_round_feedback")
@JsonIgnoreProperties(value={"hibernate_lazy_initializer","handler","fieldHandler"})
public class CourseRoundFeedback {

    @Id
    @GeneratedValue
    private Long id;

    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    @JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
    @JsonIdentityReference(alwaysAsId=true)
    private CourseRound courseRound;

    /** 反馈内容 */
    @Type(type = "text")
    private String description;

    /** 反馈时间 */
    private Date createTime;

    /** 处理时间 */
    private Date handleTime;

    /** 备注 */
    private String remark;

    /** 处理人 */
    @ManyToOne(fetch = FetchType.LAZY, optional = true)
    @JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
    @JsonIdentityReference(alwaysAsId=true)
    private Principal handler;

    public CourseRoundFeedback() {
        
    }

    /**
     * 
     * @param courseRound
     * @return
     */
    public CourseRoundFeedback initialize(CourseRound courseRound) {
        this.courseRound = courseRound;
        this.createTime = new Date();
        return this;
    }

    /**
     * 
     * @param remark
     * @param handler
     * @return
     */
    public CourseRoundFeedback handle(String remark, Principal handler) {
        this.handleTime = new Date();
        this.remark = remark;
        this.handler = handler;
        return this;
    }

    /**
     * @return the id
     */
    public Long getId() {
        return id;
    }

    /**
     * @param id the id to set
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * @return the courseRound
     */
    public CourseRound getCourseRound() {
        return courseRound;
    }

    /**
     * @param courseRound the courseRound to set
     */
    public void setCourseRound(CourseRound courseRound) {
        this.courseRound = courseRound;
    }

    /**
     * @return the description
     */
    public String getDescription() {
        return description;
    }

    /**
     * @param description the description to set
     */
    public void setDescription(String description) {
        this.description = description;
    }

    /**
     * @return the createTime
     */
    public Date getCreateTime() {
        return createTime;
    }

    /**
     * @param createTime the createTime to set
     */
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    /**
     * @return the handleTime
     */
    public Date getHandleTime() {
        return handleTime;
    }

    /**
     * @param handleTime the handleTime to set
     */
    public void setHandleTime(Date handleTime) {
        this.handleTime = handleTime;
    }

    /**
     * @return the remark
     */
    public String getRemark() {
        return remark;
    }

    /**
     * @param remark the remark to set
     */
    public void setRemark(String remark) {
        this.remark = remark;
    }

    /**
     * @return the handler
     */
    public Principal getHandler() {
        return handler;
    }

    /**
     * @param handler the handler to set
     */
    public void setHandler(Principal handler) {
        this.handler = handler;
    }
}
